#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_
#include <QtGui>
#include <QHBoxLayout>;
#include "view.h"
#include "Food.h"
#include "Jamnik.h"
#include "Settings.h"
#include "BottomWidget.h"
#include "RightWidget.h"
#include "InputDialog.h"
#include "Server.h"
#include "Score.h"
#include "Timer.h";

class MainWindow : public QMainWindow{

	Q_OBJECT

public:
	MainWindow(QWidget *parent = 0); // konstruktor

public slots:
	void newGame(); // przygotowuje wszystko potrzebne do rozpoczecia nowej gry
	void onHostGame();
	void onFoodEaten(QPoint);
	void startServer(QString);
	void connectToServer(QString host, QString port);
	void onConnStateChanged(QAbstractSocket::SocketState);
	void joinGame(QString);
	void onNewMessage(ConnectionPlayer* conn, QString cmd, QStringList args);
	void changeNick(QString);
	void onReadyClicked();
	void onLeaveClicked();
	void onDirectionChanged(QString d);

private:
	void setupMenus(); // konfiguracja menu
	void clearScene(bool deleteScene = false); //czysci plansze
	void deletePlayers();
	void deleteFood();
	void deletePlayerList();
	void deleteFoodList();
	void createPlayers();
	void createFood();
	View* view;  // widok planszy
	QGraphicsScene* scene; // nasza plansza
	Settings settings; //globalne ustawienia gry
	Jamnik* player; //tablica graczy
	Food* food;
	QTimer timer;
	QVector<Jamnik*> playerList;
	QVector<Food*> foodList;

	BottomWidget * bottomWidget;
	RightWidget * rightWidget;
	Score* leftWidget;
	QToolBar *rightToolBar;
	QToolBar *bottomToolBar;
	QToolBar *leftToolBar;
	Server *server;
	ConnectionPlayer *servConn;

	enum GameState { gameNotStarted, roundFinished, gameStarted };
	GameState gameState;
};

#endif /* MAINWINDOW_H_ */
